home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / +look_here_1st!+ / reader_requests / alienbreed3d2 / cheesesauce / serial.s < prev    next >
Text File  |  1997-11-28  |  2KB  |  119 lines

  1.     SECTION Proggy,CODE
  2.  
  3. SERPER    equ    $032
  4. SERDATR    equ    $018
  5. SERDAT    equ    $030
  6. INTREQ    equ    $09C
  7. INTENA    equ    $09A
  8. INTENAR    equ    $01C
  9. DMACON    equ    $096
  10. BPLCON0    equ    $100
  11. BPLCON1    equ    $102
  12. COL0    equ    $180
  13. OPENLIB        equ    -552
  14. CLOSELIB    equ    -414
  15.  
  16. WM MACRO
  17. \@waituntilpressed:
  18.     btst    #6,$bfe001
  19.     bne.s    \@waituntilpressed
  20. \@waituntilreleased:
  21.     btst    #6,$bfe001
  22.     beq.s    \@waituntilreleased
  23.     ENDM
  24.     
  25.     
  26.     ;first we get the command line
  27.     move.b    (a0),commandline
  28.     
  29.     ;then we must turn off the system
  30.     move.l    4.w,a6        ;get execbase
  31.     move.l    #gfxname,a1    ;point to 'graphics.library'
  32.     moveq    #0,d0
  33.     jsr    OPENLIB(a6)
  34.     move.l    d0,a1
  35.     move.l    38(a1),old    ;store workbench copper list
  36.     move.l    4.w,a6
  37.     jsr    CLOSELIB(a6)
  38.     move.l    #$dff000,a6    ;get custom address
  39.     move.w    #$87c0,DMACON(a6)
  40.     move.w    #$0020,DMACON(a6)
  41.     move.w    INTENAR(a6),saveinters
  42.     move.w    #$7fff,INTENA(a6)
  43.     move.l    #copper,$dff080
  44.     
  45.     move.w    #184,SERPER(a6)    ;19200 baud, 8 bits, no parity
  46.     move.w    #$f00,COLOUR
  47.     WM
  48.     move.b    commandline,d1        ;get command line
  49.     cmp.b    #"r",d1
  50.     beq.s    RECIEVEMODE
  51. SENDMODE:
  52.     move.w    #$0ff,COLOUR
  53.     move.l    #senddata,a0
  54.     move.l    #recdata,a1
  55.     move.l    (a0)+,d0
  56.     bsr    SENDFIRST
  57.     move.l    d0,(a1)+
  58.     move.l    (a0)+,d0
  59.     bsr    SENDFIRST
  60.     move.l    d0,(a1)+
  61.     move.l    (a0)+,d0
  62.     bsr    SENDFIRST
  63.     move.l    d0,(a1)+
  64.     move.w    #$0f0,COLOUR
  65.     bra.s    ENDOFPROG
  66. RECIEVEMODE:
  67.     move.w    #$ff0,COLOUR
  68.     move.l    #senddata,a0
  69.     move.l    #recdata,a1
  70.     move.l    (a0)+,d0
  71.     bsr    RECEIVEFIRST
  72.     move.l    d0,(a1)+
  73.     move.l    (a0)+,d0
  74.     bsr    RECEIVEFIRST
  75.     move.l    d0,(a1)+
  76.     move.l    (a0)+,d0
  77.     bsr    RECEIVEFIRST
  78.     move.l    d0,(a1)+
  79.     move.w    #$00f,COLOUR
  80.     
  81. ENDOFPROG:
  82.     WM
  83.     move.w    #$000,COLOUR
  84.     ;this little bit of code restores the system
  85.     ;first we must wait and make sure any serial transfer has finished
  86.     ;(we don't want the system jumping in and stopping things)
  87. SERFINWAIT:
  88.     btst    #4,SERDATR(a6)
  89.     beq.s    SERFINWAIT
  90.     move.l    old,$dff080    ;restore the workbench copper list
  91.     move.w    #$8020,DMACON(a6)
  92.     move.w    saveinters,d0
  93.     or.w    #$c000,d0
  94.     move.w    d0,INTENA(a6)
  95.     clr.w    $dff0a8
  96.     clr.w    $dff0b8
  97.     clr.w    $dff0c8
  98.     clr.w    $dff0d8
  99.     rts
  100.     
  101.     include "serial.inc"
  102.         
  103. old:        dc.l    0
  104. saveinters:    dc.w    0
  105. senddata:    dc.b    "Hello World",0
  106.     even
  107. recdata:    ds.b    100
  108. gfxname:    dc.b    "graphics.library",0
  109. commandline:    dc.b    0
  110.  
  111.     SECTION Copper_List,CODE_C
  112. ;here is our copper list (what there is of it)
  113. copper:
  114.     dc.w    BPLCON0,$0201    ;turn of all bitplanes
  115.     dc.w    BPLCON1,0
  116.     dc.w    COL0
  117. COLOUR:    dc.w    0
  118.     dc.w    $ffff,$fffe
  119.